package BookLibrary;

import java.util.StringTokenizer;

public class Book
{

    private int id;
    private String name;
    private String author;

    public Book(int id, String name, String autor) {
        this.id = id;
        this.name = name;
        this.author = autor;
    }

    public Book(String fromFile) {
        StringTokenizer tokenizer = new StringTokenizer(fromFile, " - ");
        this.id = Integer.parseInt(tokenizer.nextToken());
        this.name = tokenizer.nextToken();
        this.author = tokenizer.nextToken();
    }

    public String Encode() {

        return id + " -  " + name + " - " + author;

    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getAutor() {
        return author;
    }

    @Override
    public String toString() {
        return id + " - " + name + " - " + author;
    }

}
